package main.java.indi.zyj.c150.recursion;

public class _02_TowerOfHanoi {

    public static void main(String[] args) {
        Hanoi(3, "A", "B", "C");
    }

    static void Hanoi(int N, String from, String to, String help){

        if (N == 1){
            System.out.println("Move " + N + ":" + from + "--->" + to);
        }else {
            // 借用目标盘 将N-1个盘子转移到辅助盘上
            Hanoi(N - 1, from, help, to);
            // 之后可以把N移到目标盘上, 此时这个盘子可以认为空
            System.out.println("Move " + N + ":" + from + "--->" + to);
            // 然后将辅助盘上的N-1移到目标盘上去，借用原盘辅助
            Hanoi(N - 1, help, to, from);

        }
    }

}
